<?
$event = $this->event;       
?>
<script type="text/javascript">
//Change class name: 
function ChangeClass(sid,sclassname) { 
	$('#'+sid).attr('class', sclassname);
} 
</script>
								<div id="c_binhluan" class="content_block" style="padding:0px;">
									<div id="comment_detail">
										<?
										for ($i=0; $i<count($this->comments); $i++)
										{
										    $c=$this->comments[$i];
										    $avatar = EVENT_STATIC_SERVER."/images/nophoto.gif";
										    if($c->avatar != '')
										    	$avatar = "http://img.tamtay.vn/".$c->avatar;
										?>
										<div class="item09 underline" style="padding-top: 3px;">
											<div class="inputMess02">
				                                <div class="float-left"><a href="http://www.tamtay.vn/home/<?= $c->uname ?>"><img src="<?php echo $avatar;?>" width="60" /></a></div>
				                                <div class="del-reply">
				                                	<?php if ($this->isEventAdmin){ ?>
				                                	<a href="#" onclick="return event_comment.deleteComment('<?= $c->cid ?>')" ><img src="<?php echo EVENT_STATIC_SERVER;?>/images/icons/spacer.gif" id="btn_close_<?= $c->cid ?>" alt="Xóa comment này" onmouseout="javascript:ChangeClass('btn_close_<?= $c->cid ?>','btn_close')" onmouseover="javascript:ChangeClass('btn_close_<?= $c->cid ?>','btn_close_hover')" class="btn_close"/></a>
				                                	<?php }?>
				                                	<?php 
													if ($this->user->uid > 0 && (!isset($this->replies[$c->cid]) || count($this->replies[$c->cid])<=0)){ 
													?>
				                                	<a href="#" onclick="return event_comment.showReplyBox(<?= $c->cid ?>)"><img src="<?php echo EVENT_STATIC_SERVER;?>/images/icons/arrow_rotate_clockwise.png" width="16" height="16" style="margin-top:5px;" class="display-block"/></a>
				                                	<?php }?> 
				                                </div>
				                                <div class="text relative">
				                                    <div> <a href="http://www.tamtay.vn/home/<?= $c->uname ?>" class="bold"><?= $c->uname ?></a>: <?=$this->smilleyParser($c->content) ?></div>
				                                    <div class="inputTime">(<?= date("H:i:s d/m/Y", $c->created) ?>)</div>
				                                    <div class="clear"></div>
				                                </div>
				                                <div class="clear"></div>
				                            </div>
				                            <div class="commentWrap-lv2 relative">
				                            	<?php if (isset($this->replies[$c->cid])){ ?>
										        <?php 
										            $replies = $this->replies[$c->cid];
										            $numOfReplies = count($replies);
										        ?>
										        <?php if ($numOfReplies > 2){ ?>  
										        <div class="inputMess05" id="display_reply_<?= $c->cid ?>">
										            <a href="#" onclick="return event_comment.showReply(<?= $c->cid ?>)" >Hiển thị tất cả <?= $numOfReplies ?> trả lời...</a>
										        </div>
										       <?php }?>
										       <?php for ($j = 0; $j < $numOfReplies; $j++){ 
											            $reply = $replies[$j];                      
											            if ($j < ($numOfReplies - 2)) {
											                $style = 'display:none;'; 
											            } else {
											                $style = '';
											            }
											            $avatar = EVENT_STATIC_SERVER."/images/nophoto.gif";
											            if($reply->avatar != '')
										    				$avatar = "http://img.tamtay.vn/".$reply->avatar;
										        ?>
				                                    <div class="inputMess03 reply_comment_<?= $c->cid ?>" style="<?= $style ?>">
				                                        <div class="float-left relative"><a href="http://www.tamtay.vn/home/<?= $reply->uname ?>"><img src="<?php echo $avatar;?>" width="40" /></a></div>
				                                        <div class="del-reply">
				                                        	<?php if ($this->isEventAdmin){ ?>
				                                        	<a href="#" onclick="return event_comment.deleteComment('<?= $reply->cid ?>')"><img src="<?php echo EVENT_STATIC_SERVER;?>/images/icons/spacer.gif" id="btn_close_<?= $reply->cid ?>" alt="Xóa comment này" onmouseout="javascript:ChangeClass('btn_close_<?= $reply->cid ?>','btn_close')" onmouseover="javascript:ChangeClass('btn_close_<?= $reply->cid ?>','btn_close_hover')" class="btn_close"/></a>
				                                        	<?php }?> 
				                                        </div>
				                                        <div class="text">
				                                            <div><a href="http://www.tamtay.vn/home/<?= $reply->uname ?>" class="bold"><?= $reply->uname ?></a>: <?= $this->smilleyParser($reply->content) ?></div>
				                                            <div class="inputTime">(<?= date("H:i:s d/m/Y", $reply->created) ?>)</div>
				                                            <div class="clear"></div>
				                                        </div>
				                                    </div>
				                                    <?php }//end for loop?>
				                                    <?php if (count($this->replies[$c->cid]) > 0){ ?>
											            <?php if ($this->user->uid > 0){ ?>
											            <div class="inputMess05" id="reply_hint_<?= $c->cid ?>">
											                <input name="" type="text" class="inputText" value="Viết bình luận của bạn..." onclick="event_comment.showReplyBox(<?= $c->cid ?>)"/>
											            </div>
											            <?php } ?>
											        <?php } ?>
											    <?php }?>
				                                    <div class="inputMess04" id="reply_box_<?= $c->cid ?>" style="display: none;">
				                                    <?php 
											        	$avatar = EVENT_STATIC_SERVER."/images/nophoto.gif";
											        	if(isset($this->user->picture) && $this->user->picture != "")
											        		$avatar = "http://img.tamtay.vn/".$this->user->picture;
											        ?>
				                                        <div class="float-left relative"><a href="http://www.tamtay.vn/home/<?= (isset($this->user->name)?$this->user->name:"") ?>"><img src="<?php echo $avatar;?>" width="40" /></a></div>
				                                        
				                                        <div class="text02">
				                                            <fieldset style="border:0;padding:0;"><div><textarea id="comment_content_<?= $c->cid ?>" name="comment_content" style="margin: 0px 0px 3px;"></textarea></div></fieldset>
				                                            <div class="clear"></div>
				                                            <input name="" type="button" value="Gửi" class="buttonAll" onclick="event_comment.saveComment(<?= $event->eid?>, <?= $c->cid ?>)"/>
				                                            <div class="clear"></div>
				                                        </div>
				                                        
				                                        <div class="clear"></div>
				                                    </div>
				                                
				                            </div>
				                        </div>
			                            <?php }// end for loop?>
									</div>
								   <?
								   if ($this->comment_count>0)
								   {
										$page_count=ceil($this->first_level_comment_count/EVENT_COMMENT_PER_PAGE);
										$from=$this->current_page-3;
										if ($from<0)
										{
											$from=0;
										}
										$to=$this->current_page+3;
										if ($to>$page_count)
										{
											$to=$page_count;
										}
										
										echo '<p style="text-align: right">Trang ';
										if ($from>0)
										{
											echo '<a href="#" onclick="return event_comment.loadComment(' . $event->eid . ',0)">|&lt;</a>&nbsp;';
											echo '<a href="#" onclick="return event_comment.loadComment(' . $event->eid . ',' . ($i-1) . ')">&lt;&lt;</a>&nbsp;';
											echo '&nbsp;...&nbsp;';
										}
										for ($i=$from; $i<$to; $i++)
										{
											if ($i==$this->current_page)
											{
												echo '<strong>' . ($i+1) . '</strong>&nbsp;';
											}
											else
											{
												echo '<a href="#" onclick="return event_comment.loadComment(' . $event->eid . ',' . $i . ')">' . ($i+1) . '</a>&nbsp;';
											}
										}
										if ($to<$page_count-1)
										{
											echo '&nbsp;...&nbsp;';
											echo '<a href="#" onclick="return event_comment.loadComment(' . $event->eid . ',' . ($this->current_page+1) . ')">&gt;&gt;</a>&nbsp;';
											echo '<a href="#" onclick="return event_comment.loadComment(' . $event->eid . ',' . ($page_count-1) . ')">&gt;|</a>&nbsp;';
										}
										echo '</p>';
									}
									?>
								</div>